package com.gz.mylife.util;

import android.content.Context;

import com.igexin.sdk.PushManager;
import com.igexin.sdk.Tag;
import com.zl.smartmall.library.account.IAuth;
import com.zl.smartmall.library.util.Tools;

public class PushUtils {

	public static final String JTYPE_PRIVATE_LETTER = "20"; // 私信
	
	public static String buildTag(Context context) {
		//版本
		int len = 0;
		Tag[] tags = new Tag[len + 4];
		Tag versionTag = new Tag();
		versionTag.setName((Tools.getAppVersionName(context))
				.replace(".", "_"));
		tags[len] = versionTag;
		// 渠道
		Tag channelTag = new Tag();
		channelTag.setName(Tools.getChannelName(context));
		tags[len + 1] = channelTag;
		// 分段
		Tag sectionTag = new Tag();
		sectionTag.setName("SECTION_"
				+ IAuth.getInstance().loadUserInfo().getUid() / 30000);
		tags[len + 2] = sectionTag;

		// 性别
		Tag genderTag = new Tag();
		if (IAuth.getInstance().loadUserInfo().getGender() == 1) {
			genderTag.setName("SEX_MALE");
		} else {
			genderTag.setName("SEX_FEMALE");
		}
		tags[len + 3] = genderTag;
		
		PushManager.getInstance().setTag(context, tags);//给推送注册
		
		StringBuilder sbtags = new StringBuilder();
		for (int i = 0; i < tags.length; i++) {
			sbtags.append(tags[i].getName() + ",");
		}

		return sbtags.substring(0, sbtags.length() - 1);
	}
}
